<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //父类
        function Animal(){};
        Animal.prototype={
            constructor:Animal,
            eat:function(){
                console.log('动物在吃东西');
            }
        };

        //子类
        function Cat(){
        }
        Cat.prototype=new Animal();
        Cat.prototype.eat=function(){  //覆盖原型中的eat方法，重写
            //调用父类的eat方法
            Animal.prototype.eat.call(this);
            console.log("猫在吃鱼");
        }

        var cat=new Cat();
        cat.eat();
    </script>
</body>
</html>